package com.winhxd.b2c.admin.module.customer.controller;

import com.winhxd.b2c.admin.common.context.UserManager;
import com.winhxd.b2c.admin.common.security.annotation.CheckPermission;
import com.winhxd.b2c.common.constant.BusinessCode;
import com.winhxd.b2c.common.context.AdminUser;
import com.winhxd.b2c.common.context.UserContext;
import com.winhxd.b2c.common.domain.PagedList;
import com.winhxd.b2c.common.domain.ResponseResult;
import com.winhxd.b2c.common.domain.customer.condition.*;
import com.winhxd.b2c.common.domain.customer.model.CustomerUserInfo;
import com.winhxd.b2c.common.domain.customer.vo.*;
import com.winhxd.b2c.common.domain.system.security.enums.PermissionEnum;
import com.winhxd.b2c.common.domain.system.user.vo.UserInfo;
import com.winhxd.b2c.common.exception.BusinessException;
import com.winhxd.b2c.common.feign.customer.CustomerServiceClient;
import feign.Param;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author
 * @Description: 会员管理
 * @date 2019/1/7
 */
@Api(value = "后台会员管理", tags = "后台会员管理接口")
@RestController
@RequestMapping(value = "customer/user")
//@CheckPermission(PermissionEnum.CUSTOMER_MANAGEMENT)
public class CustomerUserController {

    private static final String MODULE_NAME = "后台分销商和用户管理";

    private Logger logger = LoggerFactory.getLogger(CustomerUserController.class);

    @Resource
    private CustomerServiceClient customerServiceClient;

    /**
     * 添加一级分销商
     * 王泽坤
     * @param condition
     * @return
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_ADD_FIRST)
    @ApiOperation(value = "添加一级分销商", notes = "添加一级分销商")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "添加一级分销商成功"),
                   @ApiResponse(code = BusinessCode.CODE_200001, message = "添加一级分销商信息失败")})
    @PostMapping(value = "/saveFirstDistributer")
    public ResponseResult<Boolean> saveFirstDistributer(@RequestBody CustomerDistributorCondition condition) {
        UserInfo info=UserManager.getCurrentUser();
        condition.setUpdatedBy(info.getId());
        condition.setUpdatedByName(info.getUsername());
        ResponseResult<Boolean> responseResult = customerServiceClient.saveFirstDistributer(condition);
        return responseResult;
    }

    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL)
    @ApiOperation(value = "查询分销商渠道类型列表", notes = "用户查询分销商渠道类型列表")
    @PostMapping(value = "/findCustomerDistribtorChannelTypeList")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"), @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部错误")})
    public ResponseResult<PagedList<CustomerDistributorChannelTypeVO>> findCustomerDistribtorChannelTypeList(@RequestBody DistributorChannelTypeCondition condition) {
        ResponseResult<PagedList<CustomerDistributorChannelTypeVO>> responseResult = customerServiceClient.findCustomerDistribtorChannelTypeList(condition);
        return responseResult;
    }

    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL_TYPE_EDIT_STATUS)
    @ApiOperation(value = "更新分销商渠道类型状态", notes = "更新分销商渠道类型状态")
    @PostMapping(value = "/modifyDistriButorType")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"), @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部错误")})
    public ResponseResult<Boolean> modifyDistriButorType(@RequestBody DistributorChannelTypeCondition condition) {
        UserInfo currentUser = UserManager.getCurrentUser();
        condition.setUpdatedBy(currentUser.getId());
        condition.setUpdatedByName(currentUser.getUsername());
        ResponseResult<Boolean> responseResult = customerServiceClient.modifyDistriButorType(condition);
        return responseResult;
    }

    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 分销商列表(包含模糊查询)
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_LIST_MANAGEMENT)
    @ApiOperation(value = "分销商列表", notes = "分销商列表")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "查询分销商列表成功"),
                   @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/findDistributerListByCondition")
    public ResponseResult<PagedList<CustomerDistributorVO>> findDistributerListByCondition(@RequestBody CustomerDistributorCondition condition) {
        logger.info("{} - 查询分销商列表, 参数：condition={}", MODULE_NAME, condition);
        return customerServiceClient.findDistributerListByCondition(condition);
    }

    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 一级分销商换绑
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MODIFY_FIRST_BIND)
    @ApiOperation(value = "一级分销商换绑", notes = "一级分销商换绑")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "一级分销商换绑成功"),
                   @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/modifyFirstDistributorBind")
    public ResponseResult<Boolean> modifyFirstDistributorBind(@RequestBody CustomerDistributorCondition condition) {
        UserInfo info=UserManager.getCurrentUser();
        condition.setUpdatedBy(info.getId());
        condition.setUpdatedByName(info.getUsername());
        return customerServiceClient.modifyFirstDistributorBind(condition);
    }

    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 二级分销商换绑
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MODIFY_SECOND_BIND)
    @ApiOperation(value = "二级分销商换绑", notes = "二级分销商换绑")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "二级分销商换绑成功"),
                   @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/modifySecondDistributorBind")
    public ResponseResult<Boolean> modifySecondDistributorBind(@RequestBody CustomerDistributorCondition condition) {
        UserInfo info=UserManager.getCurrentUser();
        condition.setUpdatedBy(info.getId());
        condition.setUpdatedByName(info.getUsername());
        return customerServiceClient.modifySecondDistributorBind(condition);
    }

    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 修改分销商状态
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MODIFY_DISTRIBUTOR_STATUS)
    @ApiOperation(value = "修改分销商状态", notes = "修改分销商状态")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "修改分销商状态成功"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/modifyDistributorStatus")
    public ResponseResult<Boolean> modifyDistributorStatus(@RequestBody CustomerDistributorCondition condition) {
        return customerServiceClient.modifyDistributorStatus(condition);
    }

    /**
     * @param channelCondition
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/7
     * @Description 修改分销商状态
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL_ADD)
    @ApiOperation(value = "新增分销商渠道", notes = "新增分销商渠道")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "新增分销商渠道成功"),  })
    @PostMapping(value = "/saveDistriButorChannel")
    public ResponseResult<Boolean> saveDistriButorChannel(@RequestBody DistributorChannelCondition channelCondition) {
        UserInfo currentUser = UserManager.getCurrentUser();
        channelCondition.setCreatedBy(currentUser.getId());
        channelCondition.setCreatedByName(currentUser.getUsername());
        channelCondition.setUpdatedBy(currentUser.getId());
        channelCondition.setUpdatedByName(currentUser.getUsername());
        return customerServiceClient.saveDistriButorChannel(channelCondition);
    }

    /**
     * @param id
     * @return
     * @author 王泽坤
     * @date 2019/1/8
     * @Description 根据主键查询分销商换绑所需要的简单信息
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_SIMPLE)
    @ApiOperation(value = "根据主键查询分销商换绑所需要的简单信息", notes = "根据主键查询分销商换绑所需要的简单信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "根据主键查询分销商换绑所需要的简单信息成功"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @GetMapping(value = "/findDistributerSimpleById/{id}")
    public ResponseResult<CustomerDistributorSimpleVO> findDistributerSimpleById(@PathVariable(value = "id") Long id) {
        return customerServiceClient.findDistributerSimpleById(id);
    }

    /**
     * @param id
     * @return
     * @author 王泽坤
     * @date 2019/1/8
     * @Description 根据主键查询分销商详细信息
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_DETAIL)
    @ApiOperation(value = "根据主键查询分销商详细信息", notes = "根据主键查询分销商详细信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "根据主键查询分销商详细信息"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @GetMapping(value = "/findDistributerDeatilById/{id}")
    public ResponseResult<CustomerDetailVO> findDistributerDeatilById(@PathVariable(value = "id") Long id) {
        return customerServiceClient.findDistributerDeatilById(id);
    }

    /**
     * 分销商/会员基本信息汇总
     * @author: wangbaokuo
     * @date: 2019/1/11 11:00
     * @param: [id]
     * @return: com.winhxd.b2c.common.domain.ResponseResult<com.winhxd.b2c.common.domain.customer.vo.CustomerBaseCollectVO>
     */
    @CheckPermission(PermissionEnum.SYSTEM_MANAGEMENT)
    @ApiOperation(value = "分销商/会员基本信息汇总， 会员累计获得积分/收益复用", notes = "分销商/会员基本信息汇总， 会员累计获得积分/收益复用")
    @ApiResponses({
            @ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/findUserBaseCollect")
    public ResponseResult<List<CustomerBaseCollectVO>> findUserBaseCollect(@RequestBody CustomerWalletCondition condition){
        return customerServiceClient.findCustomerWallet(condition);
    }

    /**
     * 分销商/会员详情-收益日志
     * @author: wangbaokuo
     * @date: 2019/1/11 11:43
     * @param: [id]
     * @return: com.winhxd.b2c.common.domain.ResponseResult<com.winhxd.b2c.common.domain.customer.vo.CustomerRevenueDetailVO>
     */
    @CheckPermission(PermissionEnum.SYSTEM_MANAGEMENT)
    @ApiOperation(value = "分销商/会员详情-收益日志", notes = "分销商/会员详情-收益日志")
    @ApiResponses({
            @ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/findUserRevenueDetail")
    public ResponseResult<PagedList<CustomerRevenueDetailVO>> findUserRevenueDetail(@RequestBody CustomerRevenueDetailCondition condition){
        return customerServiceClient.findUserRevenueDetail(condition);
    }

    /**
     * 分销商/会员详情-积分日志
     * @author: wangbaokuo
     * @date: 2019/1/11 11:43
     * @param: [id]
     * @return: com.winhxd.b2c.common.domain.ResponseResult<com.winhxd.b2c.common.domain.customer.vo.CustomerIntegralDetailVO>
     */
    @CheckPermission(PermissionEnum.SYSTEM_MANAGEMENT)
    @ApiOperation(value = "分销商/会员详情-积分日志", notes = "分销商/会员详情-积分日志")
    @ApiResponses({
            @ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/findUserIntegralDetail")
    public ResponseResult<PagedList<CustomerIntegralDetailVO>> findUserIntegralDetail(@RequestBody CustomerIntegralDetailCondition condition){
        return customerServiceClient.findUserIntegralDetail(condition);
    }

    /**
     * 提现记录列表
     * @author: wangbaokuo
     * @date: 2019/1/11 16:12
     * @param: []
     * @return: com.winhxd.b2c.common.domain.ResponseResult<com.winhxd.b2c.common.domain.PagedList<com.winhxd.b2c.common.domain.customer.vo.PayWithdrawalsVO>>
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_WITHDRAW_MANAGEMENT)
    @ApiOperation(value = "提现记录列表", notes = "提现记录列表")
    @ApiResponses({
            @ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/findPayWithdrawals")
    public ResponseResult<PagedList<CustomerWithdrawalsVO>> findPayWithdrawals(@RequestBody CustomerWithdrawalsCondition condition){
        return customerServiceClient.findPayWithdrawals(condition);
    }

    @CheckPermission(PermissionEnum.DISTRIBUTOR_WITHDRAW_MANAGEMENT)
    @ApiOperation(value = "审核提现记录", notes = "审核提现记录")
    @ApiResponses({
            @ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/auditPayWithdrawals")
    public ResponseResult<Integer> auditPayWithdrawals(@RequestBody CustomerAuditCondition condition){
        AdminUser adminUser = UserContext.getCurrentAdminUser();
        if (null == adminUser) {
            throw new BusinessException(BusinessCode.CODE_1002);
        }
        condition.setUpdatedBy(adminUser.getId());
        condition.setUpdatedByName(adminUser.getUsername());
        return customerServiceClient.auditPayWithdrawals(condition);
    }



    /**
     * @param id
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/9
     * @Description 根据主键查询分销商详细信息
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL_DETAIL_INFO)
    @ApiOperation(value = "根据主键查询分销商渠道详细信息", notes = "根据主键查询分销商渠道详细信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "根据主键查询分销商渠道详细信息"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "分销商渠道id为空")})
    @PostMapping(value = "/getDistributerChannelLevelById/{id}")
    public ResponseResult<CustomerDistributorTypeAndChannelVO> getDistributerChannelLevelById(@PathVariable(value = "id") Long id) {
        return customerServiceClient.getDistributerChannelLevelById(id);
    }

    @CheckPermission(PermissionEnum.MEMBER_DETAIL_INFO)
    @ApiOperation(value = "查询会员基本信息")
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/getCustomerUserInfoById")
    public ResponseResult<CustomerUserInfoVO> getCustomerUserInfoById(@PathVariable(value = "customerId") Long customerId) {
        logger.info("查询会员基本信息, 参数：getCustomerUserInfoById={}", customerId);
        return customerServiceClient.getCustomerUserInfoById(customerId);
    }

    @ApiOperation(value = "查询会员渠道信息")
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL_DETAIL_INFO)
    @ApiResponses({ @ApiResponse(code = BusinessCode.CODE_OK, message = "成功"),
            @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部异常"),
            @ApiResponse(code = BusinessCode.CODE_1007, message = "参数无效")})
    @PostMapping(value = "/getCustomerChannelById")
    public ResponseResult<CustomerDistributorTypeAndChannelVO> getCustomerChannelById(@PathVariable(value = "customerId") Long customerId) {
        logger.info("查询会员渠道信息, 参数：getCustomerChannelById={}", customerId);
        return customerServiceClient.getCustomerChannelById(customerId);
    }

    /**
     * @param
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/9
     * @Description 查询所有的分销商渠道类型列表
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL)
    @ApiOperation(value = "查询分销商渠道类型列表", notes = "查询分销商渠道类型列表")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "查询分销商渠道类型列表"),})
    @PostMapping(value = "/findDistributerChannelTypeList")
    public ResponseResult<List<CustomerDistributorChannelTypeVO>> findDistributerChannelTypeList(@RequestBody DistributorChannelTypeCondition condition) {
        logger.info("{} - 查询分销商渠道类型列表, 参数：condition={}", MODULE_NAME, condition);
        ResponseResult<List<CustomerDistributorChannelTypeVO>> result= customerServiceClient.findDistributerChannelTypeList(condition);
        return result;
    }

    /**
     * @param
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/9
     * @Description 查询所有的分销商渠道类型列表
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_MANAGEMENT_CHANNEL)
    @ApiOperation(value = "查询有效分销商渠道类型列表", notes = "查询有效分销商渠道类型列表")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "查询分销商渠道类型列表"),})
    @PostMapping(value = "/findDistributerChannelValidTypeList")
    public ResponseResult<List<CustomerDistributorChannelTypeVO>> findDistributerChannelTypeList() {
        logger.info("{} - 查询有效分销商渠道类型列表, 参数：condition={}", MODULE_NAME);
        DistributorChannelTypeCondition condition1 = new DistributorChannelTypeCondition();
        condition1.setChannelStatus(1);
        ResponseResult<List<CustomerDistributorChannelTypeVO>> result= customerServiceClient.findDistributerChannelTypeList(condition1);
        return result;
    }

    /**
     * @param condition
     * @return  CustomerStoreVO
     * @author zhaoyanbiao
     * @date 2019/1/11
     * @Description 查询用户门店信息列表
     */
    @CheckPermission(PermissionEnum.STORE_MANAGEMENT_STORE)
    @ApiOperation(value = "查询用户门店信息列表", notes = "查询用户门店信息列表")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "查询用户门店信息列表成功"),})
    @PostMapping(value = "/findCustomerStoreList")
    public ResponseResult<PagedList<CustomerStoreVO>> findCustomerStoreList(@RequestBody CustomerStoreInfoCondition condition) {
        logger.info("{} - 查询用户门店信息列表, 参数：condition={}", MODULE_NAME, condition);
        ResponseResult<PagedList<CustomerStoreVO>> result= customerServiceClient.findCustomerStoreList(condition);
        return result;
    }


    /**
     * @param condition
     * @return  CustomerStoreVO
     * @author zhaoyanbiao
     * @date 2019/1/11
     * @Description 查询用户门店信息列表
     */
    @ApiOperation(value = "修改用户门店信息", notes = "修改用户门店信息")
    @CheckPermission(PermissionEnum.STORE_MANAGEMENT_STORE_EDIT)
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "修改用户门店信息成功"),})
    @PostMapping(value = "/modifyCustomerStoreInfo")
    public ResponseResult<Boolean> modifyCustomerStoreInfo(@RequestBody CustomerStoreInfoCondition condition) {
        logger.info("{} - 修改用户门店信息, 参数：condition={}", MODULE_NAME, condition);
        UserInfo currentUser = UserManager.getCurrentUser();
        condition.setUpdatedBy(currentUser.getId());
        condition.setUpdatedByName(currentUser.getUsername());
        ResponseResult<Boolean> result= customerServiceClient.modifyCustomerStoreInfo(condition);
        return result;
    }

    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 分销商详情保存
     */
    @CheckPermission(PermissionEnum.DISTRIBUTOR_DETAIL_SAVE)
    @ApiOperation(value = "分销商详情保存", notes = "分销商详情保存")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "分销商详情保存"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/modifyDistributor")
    public ResponseResult<Boolean> modifyDistributor(@RequestBody CustomerDistributorCondition condition) {
        UserInfo info=UserManager.getCurrentUser();
        condition.setUpdatedBy(info.getId());
        condition.setUpdatedByName(info.getUsername());
        return customerServiceClient.modifyDistributor(condition);
    }

    /**
     * @param condition
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/12
     * @Description 通过主键ID返回会员的相关信息
     */
    @CheckPermission(PermissionEnum.MEMBER_DETAIL_INFO)
    @ApiOperation(value = "通过主键ID返回会员的相关信息", notes = "通过主键ID返回会员的相关信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "通过主键ID返回会员的相关信息"), @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @RequestMapping(value = "/getCustomerUserById/{id}",method = RequestMethod.GET)
    public ResponseResult<CustomerUserInfo> getCustomerUserById(@PathVariable(value = "id") Long id) {
        return customerServiceClient.getCustomerUserById(id);
    }

    /**
     * @param customerId
     * @return
     * @author zhaoyanbiao
     * @date 2019/1/25
     * @Description 通过customerId返回上级的相关信息
     */
    @CheckPermission(PermissionEnum.MEMBER_DETAIL_INFO)
    @ApiOperation(value = "通过customerId返回上级的相关信息", notes = "通过customerId返回上级的相关信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "通过customerId返回上级的相关信息"), @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @RequestMapping(value = "/getParentCustomerUserByCustoemrId",method = RequestMethod.POST)
    public ResponseResult<CustomerUserInfo> getParentCustomerUserByCustoemrId(@RequestParam(value = "customerId") Long customerId) {
        return customerServiceClient.getParentCustomerUserByCustoemrId(customerId);
    }


    /**
     * @param condition
     * @return  CustomerStoreVO
     * @author wangzekun
     * @date 2019/1/15
     * @Description 根据渠道ID和等级查询分销商信息
     */
    @CheckPermission(PermissionEnum.MEMBER_DETAIL_INFO)
    @ApiOperation(value = "根据渠道ID和等级查询分销商信息", notes = "根据渠道ID和等级查询分销商信息")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "查询根据渠道ID和等级查询分销商信息列表成功"),})
    @PostMapping(value = "/findDistributorListByChannelIdAndLevel")
    public ResponseResult<List<CustomerUserInfoVO>> findDistributorListByChannelIdAndLevel(@RequestBody CustomerDistributorCondition condition) {
        logger.info("{} - 根据渠道ID和等级查询分销商信息列表, 参数：condition={}", MODULE_NAME, condition);
        ResponseResult<List<CustomerUserInfoVO>> result= customerServiceClient.findDistributorListByChannelIdAndLevel(condition);
        return result;
    }


    /**
     * @param condition
     * @return
     * @author 王泽坤
     * @date 2019/1/7
     * @Description 会员换绑
     */
    @CheckPermission(PermissionEnum.MEMBER_MODIFY_BIND)
    @ApiOperation(value = "会员换绑", notes = "会员换绑")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "会员换绑成功"),
            @ApiResponse(code = BusinessCode.CODE_200001, message = "用户id为空")})
    @PostMapping(value = "/modifyMemberDistributorBind")
    public ResponseResult<Boolean> modifyMemberDistributorBind(@RequestBody CustomerDistributorCondition condition) {
        UserInfo info=UserManager.getCurrentUser();
        condition.setUpdatedBy(info.getId());
        condition.setUpdatedByName(info.getUsername());
        return customerServiceClient.modifyMemberDistributorBind(condition);
    }


    @CheckPermission(PermissionEnum.STORE_MANAGEMENT_OPEN_PLAN)
    @ApiOperation(value = "查询分开店方案列表", notes = "查询分开店方案列表")
    @PostMapping(value = "/findCustomerShopPlanList")
    @ApiResponses({@ApiResponse(code = BusinessCode.CODE_OK, message = "操作成功"), @ApiResponse(code = BusinessCode.CODE_1001, message = "服务器内部错误")})
    public ResponseResult<PagedList<ShopPlanVO>> findCustomerShopPlanList(@RequestBody ShopPlanCondition condition) {
        logger.info("{} - 根据渠道ID和等级查询分销商信息列表, 参数：condition={}", MODULE_NAME, condition);
        ResponseResult<PagedList<ShopPlanVO>> result= customerServiceClient.findCustomerShopPlanList(condition);
        return result;
    }


}
